package{
	import com.PQLoad.PQLoader;
	import com.tools.EventHelper;
	import com.tools.Tip;

	public class ConfigParsing{
		/**配置路径**/
		private var url:String;
		/**资源列表**/
		private var resList:Array;
		/**配置列表**/
		private var configList:Array;
		public function ConfigParsing(){
			init();
		}
		public function init():void{
			resList=[];
			configList=[];
		}
		/**载入列表**/
		public function loadConfig(_url:String):void{
			url=_url;
			PQLoader.load(url,{onComplete:configLoaded});
		}
		/**处理配置数据**/
		private function configLoaded(...args):void{
			var xml:XML=PQLoader.getXml("config/config.xml");
			for each(var ixml:XML in xml.item){
				if(!ixml.@res)continue;
				resList.push(ixml.@res);
				configList.push({res:ixml.@res.toString(),x:parseInt(ixml.@x),y:parseInt(ixml.@y),width:parseInt(ixml.@width),height:parseInt(ixml.@height),scaleX:parseFloat(ixml.@scaleX),scaleY:parseFloat(ixml.@scaleY),alpha:parseFloat(ixml.@alpha),type:ixml.@type.toString(),parent:ixml.@parent.toString(),name:ixml.@name.toString(),rotation:parseInt(ixml.@rotation)});
			}
			if(resList.length<1)return;
			PQLoader.loadList(resList,{onComplete:resLoaded,onProgress:progress});
		}
		private function resLoaded(...args):void{
			Tip.showTip("配置载入完毕");
			EventHelper.self.call(EventType.CREATE_VIEW,configList);
		}
		private function progress(...args):void{
			
		}
	}
}